﻿using FluentValidation;
using Turquoise.Entities.Complex.UserModels;
using Turquoise.Globalization;

namespace Turquoise.Validation.FluentValidation.UserValidation.Rules
{
    public class AddRules : AbstractValidator<AddModel>
    {
        public AddRules()
        {
            RuleFor(p => p.User.Username).NotEmpty().WithMessage(Resources.UsernameNotEmpty);
            RuleFor(p => p.User.Username).Length(8, 32).WithMessage(Resources.UsernameLength);
            RuleFor(p => p.User.Password).NotEmpty().WithMessage(Resources.PasswordNotEmpty);
            RuleFor(p => p.User.Password).Length(8, 129).WithMessage(Resources.PasswordLength);
            RuleFor(p => p.User.Password).Equal(p => p.User.ConfirmPassword).WithMessage(Resources.PasswordEqual);
            RuleFor(p => p.User.Email).NotEmpty().WithMessage(Resources.EmailNotEmpty);
            RuleFor(p => p.User.Email).EmailAddress().WithMessage(Resources.EmailInValid);
            RuleFor(p => p.User.FirstName).NotEmpty().WithMessage(Resources.FirstNameNotEmpty);
            RuleFor(p => p.User.LastName).NotEmpty().WithMessage(Resources.LastNameNotEmpty);

        }
    }
}
